////////////////////////////////////////////////////////////
/* WarpNPC Script Original written by Kamyn              //
 *                                                      //
 * This script can be easily edited to be              //
 * used for your server. Throughout the script        //
 * are comments on what each thing does so that      //
 * you can edit this. You can create custom         //
 * teleporting locations and menus.                //
 *                                                //
 * Originally written for use with Moon++        //
 */                                             //
/////////////////////////////////////////////////


#include "StdAfx.h"
#include "Setup.h"

#ifdef WIN32
#pragma warning(disable:4305)
#endif

class SCRIPT_DECL WarpNPC : public GossipScript

{
public:	
	void GossipHello(Object * pObject, Player* Plr, bool AutoSend);	
	void GossipSelectOption(Object * pObject, Player* Plr, uint32 Id, uint32 IntId, const char * Code);	
	void GossipEnd(Object * pObject, Player* Plr);	
	void Destroy()	
	{
		delete this;
	}
};

void WarpNPC::GossipHello(Object * pObject, Player* Plr, bool AutoSend)
{
	GossipMenu *Menu; //Begin Main Menu
	objmgr.CreateGossipMenuForPlayer(&Menu, pObject->GetGUID(), 1/* Where this '1' is placed, you can change this number to any ID in your npc_text table*/, Plr);
	if (Plr->GetTeam() == 1)
	{
		Menu->AddItem(5, "Capital Cities", 1); //horde
	}
	else 
	{
		Menu->AddItem(5, "Capital Cities", 2); //alliance
	}
	Menu->AddItem(5, "Azeroth Instances", 5);
	Menu->AddItem(5, "Outland Instances", 6);
	Menu->AddItem(5, "Azeroth Raids", 3);
	Menu->AddItem(5, "Outland Raids", 4);
	//Uncomment below your discretion - They work fine.. just might not be suitable for your server.
	//Menu->AddItem(5, "Remove Rez Sickness", 8);
	Menu->AddItem(0, "Moon++ WarpNPC Script by Kamyn", 100);

	if(AutoSend)
		Menu->SendTo(Plr);
}

void WarpNPC::GossipSelectOption(Object * pObject, Player* Plr, uint32 Id, uint32 IntId, const char * Code)
{
	Creature * pCreature = (pObject->GetTypeId()==TYPEID_UNIT)?((Creature*)pObject):NULL;
	if(pCreature==NULL)
		return;

	GossipMenu * Menu;
	switch(IntId)
	{
	case 0:
		GossipHello(pObject, Plr, true);
		break;
		//Submenus begin below
		// These include: 
		//(a) Capitals
		//(h) Capitals
		//Azeroth Instances
		//Outland Instances
		//Azeroth Raids
		//Outland Raids
	
	case 100: //main menu return
		  {
			objmgr.CreateGossipMenuForPlayer(&Menu, pObject->GetGUID(), 1, Plr);
			if (Plr->GetTeam() == 1)
			{
				Menu->AddItem(5, "Capital Cities", 1); //horde
			}
			else 
			{
				Menu->AddItem(5, "Capital Cities", 2); //alliance
			}
				Menu->AddItem(5, "Azeroth Instances", 5);
				Menu->AddItem(5, "Outland Instances", 6);
				Menu->AddItem(5, "Azeroth Raids", 3);
				Menu->AddItem(5, "Outland Raids", 4);
				//Uncomment below your discretion - They work fine.. just might not be suitable for your server.
				//Menu->AddItem(5, "Remove Rez Sickness", 8);
				Menu->AddItem(0, "Moon++ WarpNPC Script by Kamyn", 100);
				Menu->SendTo(Plr);
		  }
		  break;
	
	case 1:
		{
			objmgr.CreateGossipMenuForPlayer(&Menu, pObject->GetGUID(), 1, Plr);
			Menu->AddItem(5, "Orgrimmar", 9);
			Menu->AddItem(5, "Undercity", 10);
			Menu->AddItem(5, "Thunder Bluff", 11);
			Menu->AddItem(5, "Silvermoon City", 12);
			Menu->AddItem(5, "Shattrath City", 51);
			Menu->AddItem(0, "[Main Menu]", 100);
			Menu->SendTo(Plr);
		}
		break;

	case 2: // Alliance Capital Cities
		{
			objmgr.CreateGossipMenuForPlayer(&Menu, pObject->GetGUID(), 1, Plr);
			Menu->AddItem(5, "Stormwind City", 14);
			Menu->AddItem(5, "Ironforge", 15);
			Menu->AddItem(5, "Darnassus", 16);
			Menu->AddItem(5, "The Exodar", 17);
			Menu->AddItem(5, "Shattrath City", 51);
			Menu->AddItem(0, "[Main Menu]", 100);
			Menu->SendTo(Plr);
		}
		break;

	case 5: //Azeroth Instances
		{
			objmgr.CreateGossipMenuForPlayer(&Menu, pObject->GetGUID(), 1, Plr);
			Menu->AddItem(5, "Shadowfang Keep", 19);
            Menu->AddItem(5, "Scarlet Monastery", 20);
			Menu->AddItem(5, "Zul'Farrak", 21);
			Menu->AddItem(5, "Stratholme", 22);
            Menu->AddItem(5, "Scholomance", 23);
			Menu->AddItem(5, "Caverns of Times", 52);
            Menu->AddItem(0, "[Main Menu]", 100);
            Menu->SendTo(Plr);
		}
		break;

	case 6: //Outland Instances
		{
			objmgr.CreateGossipMenuForPlayer(&Menu, pObject->GetGUID(), 1, Plr);
			Menu->AddItem(5, "Hellfire Ramparts", 25);
			Menu->AddItem(5, "The Blood Furnace", 26);
			Menu->AddItem(5, "The Shattered Halls", 27);
			Menu->AddItem(5, "The Underbog", 28);
			Menu->AddItem(5, "The Slave Pens", 29);
			Menu->AddItem(5, "The Steamvault", 30);
			Menu->AddItem(5, "Mana-Tombs", 31);
			Menu->AddItem(5, "Auchenai Crypts", 32);
			Menu->AddItem(5, "Sethekk Halls", 33);
			Menu->AddItem(5, "Shadow Labyrinth", 34);
			Menu->AddItem(5, "The Mechanar", 35);
			Menu->AddItem(5, "The Botanica", 36);
			Menu->AddItem(5, "The Arcatraz", 37);
			Menu->AddItem(0, "[Main Menu]", 100);
			Menu->SendTo(Plr);
		}
		break;
		
	case 3: //azeroth raids
		{
			objmgr.CreateGossipMenuForPlayer(&Menu, pObject->GetGUID(), 1, Plr);
			Menu->AddItem(5, "Blackrock Spire", 38);
			Menu->AddItem(5, "Onyxia's Lair", 39);
			Menu->AddItem(5, "Molten Core", 40);
			Menu->AddItem(5, "Zul'Gurub", 41);
			Menu->AddItem(5, "Karazhan", 42);
			Menu->AddItem(5, "Ahn'Qirai 20", 43);
            Menu->AddItem(5, "Ahn'Qirai 40", 44);
            Menu->AddItem(5, "Naxxramas", 45);
            Menu->AddItem(0, "[Main Menu]", 100);
            Menu->SendTo(Plr);
		}
		break;

	case 8: // This will remove rez sickness by teaching the spell then unlearning it. I believe there is a new command to do this to make it easier but this works fine.
		{
			objmgr.CreateGossipMenuForPlayer(&Menu, pObject->GetGUID(), 1, Plr);
            Plr->addSpell(15007);			
			Plr->removeSpell(15007,0,0,0);		
			pCreature->SendChatMessage(CHAT_MSG_MONSTER_SAY, LANG_UNIVERSAL, "Rez Sickness Removed! Stop dying FFS!" );
			Menu->AddItem(0, "[Main Menu]", 100);
            Menu->SendTo(Plr);
		}
		break;
		
		//Coords!
		//It is very easy to add coordinates.
		//In game, simple do a .gps and get the coordinates.
		//Then add them here in this style:
		//Plr->EventTeleport(mapID, xCoord, yCoord, zCoord);
		//Use the case number that you created in the menu.


	case 12://Silvermoon
		{
			Plr->EventTeleport(530, 9400.486328, -7278.376953, 14.206780);
        }
		break;

	case 9://Orgrimmar
        {
            Plr->EventTeleport(1, 1371.068970, -4370.801758, 26.052483);
        }
		break;

	case 11://ThunderBluff
		{
			Plr->EventTeleport(1, -1304.569946, 205.285004, 68.681396);
        }
		break;

    case 10://UnderCity
        {
            Plr->EventTeleport(0, 2050.203125, 285.650604, 56.994549);
        }
		break;

    case 17: //Exodar
        {
            Plr->EventTeleport(530, -4072.202393, -12014.337891, -1.277277);
        }
		break;

    case 14: //Stormwind
        {
            Plr->EventTeleport(0, -9100.480469, 406.950745, 92.594185);
        }
		break;

    case 15: //Ironforge
        {
            Plr->EventTeleport(0, -5028.265137, -825.976563, 495.301575);
        }
		break;

    case 16: //Darnassus
        {
            Plr->EventTeleport(1, 9985.907227, 1971.155640, 1326.815674);
        }
		break;
		
	case 51: //Shattrath
		{
            Plr->EventTeleport(530, -1887.510010, 5359.379883, -12.427300);
		}
		break;

	case 19: // Shadowfang Keep
		{
            Plr->EventTeleport(0, -234.495087, 1561.946411, 76.892143);
		}
		break;
	
	case 20: // Scarlet Monastery
		{
            Plr->EventTeleport(0, 2870.442627, -819.985229, 160.331085);
		}
		break;
		
	case 21: // Zul'Farrak
		{
            Plr->EventTeleport(1, -6797.278809, -2903.917969, 9.953360);
		}
		break;
		
	case 41: // Zul'Gurub
		{
            Plr->EventTeleport(0, -11919.073242, -1202.459374, 92.298744);
		}
		break;
		
	case 43: // Ahn'Qirai 20
		{
            Plr->EventTeleport(1, -8394.730469, 1485.658447, 21.038563);
		}
		break;
		
	case 44: // Ahn'Qirai 40
		{
            Plr->EventTeleport(1, -8247.316406, 1970.156860, 129.071472);
		}
		break;
		
	case 40: // Molten Core
		{
            Plr->EventTeleport(409, 1089.6, -470.19, -106.41);
		}
		break;
        
	case 39: // Onyxia
		{			
			Plr->EventTeleport(1, -4746, -3749, -4.0);
		}
		break;
		
	case 45: // Naxxramas
		{
			Plr->EventTeleport(533, 3006.06, -3436.72, 293.891);
		}
		break;
		
	case 23: //Scholomance
		{ 
			Plr->EventTeleport(0, 1267.468628, -2556.651367, 94.127983);
		}
		break;
		
	case 24: //Stratholme
		{ 
			Plr->EventTeleport(0, 3359.111572, -3380.8444238, 144.781860);
		}
		break;
                        
	case 38: // Black ROck Spire
		{ 
			Plr->EventTeleport(0, -7527.129883, -1224.997437, 285.733002);
		}
		break;
			
	case 42: // Kharazan
		{ 
			Plr->EventTeleport(532, -11087.3, -1977.47, 49.6135);
		}
		break;

	case 52: // Caverns of Times
		{ 
			Plr->EventTeleport(1, -8519.718750, -4297.542480, -208.441376);
		}
		break;

	case 25: // Hellfire Ramparts
		{ 
			Plr->EventTeleport(530, -360.670990, 3071.899902, -15.097700);
		}
		break;

	case 26: // The Blood Furnace
		{ 
			Plr->EventTeleport(530, -303.506012, 3164.820068, 31.742500);
		}
		break;

	case 27: // The Shattered Halls		
		{ 
			Plr->EventTeleport(530, -311.083527, 3083.291748, -3.745923);
		}
		break;
		
	case 28: // The Underbog
		{ 
			Plr->EventTeleport(530, 777.088989, 6763.450195, -72.062561);
		}
		break;
		
	case 29: // The Slave Pens
		{ 
			Plr->EventTeleport(530, 719.507996, 6999.339844, -73.074303);
		}
		break;
		
	case 30: // The Steamvault
		{ 
			Plr->EventTeleport(530, 816.590027, 6934.669922, -80.544601);
		}
		break;
		
	case 31: // Mana-Tombs
		{ 
			Plr->EventTeleport(530, -3079.810059, 4943.040039, -101.046997);
		}
		break;
		
	case 32: // Auchenai Crypts
		{ 
			Plr->EventTeleport(530, -3361.959961, 5225.770020, -101.047997);
		}
		break;
		
	case 33: // Sethekk Halls
		{ 
			Plr->EventTeleport(530, -3362.219971, 4660.410156, -101.049004 );
		}
		break;
		
	case 34: // Shadow Labyrinth
		{ 
			Plr->EventTeleport(530, -3645.060059, 4943.620117, -101.047997);
		}
		break;
		
	case 35: // The Mechanar
		{ 
			Plr->EventTeleport(530, 2862.409912, 1546.089966, 252.158691);
		}
		break;
		
	case 36: // The Botanica
		{ 
			Plr->EventTeleport(530, 3413.649902, 1483.319946, 182.837997);
		}
		break;
	
	case 37: // The Arcatraz
		{ 
			Plr->EventTeleport(530, 3311.598145, 1332.745117, 505.557251);
		}
		break;

	case 46: // Magtheridon's Lair
		{
			Plr->EventTeleport(530, -313.678986, 3088.350098, -116.501999);
		}
		break;

	case 47: // Serpentshrine Cavern
		{ 
			Plr->EventTeleport(530, 830.542908, 6865.445801, -63.785503);
		}
		break;

	case 48: // Gruul's Lair
		{ 
			Plr->EventTeleport(530, 3549.424072, 5179.854004, -4.430779);
		}
		break;

	case 49: // The Eye
		{ 
			Plr->EventTeleport(530, 3087.310059, 1373.790039, 184.643005);
		}
		break;

	case 50: // Black Temple
		{
			Plr->EventTeleport(530, -3609.739990, 328.252014, 37.307701 );
		}
		break;
	}
}

void WarpNPC::GossipEnd(Object * pObject, Player* Plr)
{
    GossipScript::GossipEnd(pObject, Plr);
}

void SetupWarpNPC(ScriptMgr * mgr)
{
	GossipScript * gs = (GossipScript*) new WarpNPC();
	// List of Teleporter npcs, 55555 is the id
    mgr->register_gossip_script(55555, gs);
}

//teh end